﻿using System;
using fastCSharp;
using fastCSharp.code.cSharp;

namespace diantou.dataModel.path
{
    /// <summary>
    /// 话题URL
    /// </summary>
    public struct topic
    {
        /// <summary>
        /// 话题标识
        /// </summary>
        public int Id;
        /// <summary>
        /// 话题名称
        /// </summary>
        public string Name;
        /// <summary>
        /// 查询字符串
        /// </summary>
        private string query
        {
            get { return "topicId=" + Id.toString(); }
        }
        /// <summary>
        /// 格式化URL
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        private webView.hashUrl get(string name)
        {
            return new webView.hashUrl { Path = "/topic/" + name + ".html", Query = query };
        }
        /// <summary>
        /// 首页
        /// </summary>
        public webView.hashUrl Index
        {
            get { return get("index"); }
        }
        /// <summary>
        /// 关注者
        /// </summary>
        public webView.hashUrl Focus
        {
            get { return get("focus"); }
        }
        /// <summary>
        /// 编辑日志
        /// </summary>
        public webView.hashUrl Log
        {
            get { return get("log"); }
        }
        /// <summary>
        /// 热门问答
        /// </summary>
        public webView.hashUrl Hot
        {
            get { return get("hot"); }
        }
        /// <summary>
        /// 最佳问答
        /// </summary>
        public webView.hashUrl BestAnswer
        {
            get { return get("bestAnswer"); }
        }
        /// <summary>
        /// 好友的问答
        /// </summary>
        public webView.hashUrl Friend
        {
            get { return get("friend"); }
        }
        /// <summary>
        /// 相关收藏
        /// </summary>
        public webView.hashUrl Favorite
        {
            get { return get("favorite"); }
        }
        /// <summary>
        /// 用户的回答
        /// </summary>
        public webView.hashUrl UserAnswer(int userId)
        {
            webView.hashUrl path = get("userAnswer");
            return new webView.hashUrl { Path = path.Path, Query = path.Query + "&userId=" + userId.toString() };
        }
        /// <summary>
        /// 格式化URL
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        private webView.hashUrl getPath(string path)
        {
            return new webView.hashUrl { Path = path, Query = query };
        }
        /// <summary>
        /// OJ问题列表
        /// </summary>
        public webView.hashUrl ProblemList
        {
            get { return getPath(problem.TopicList); }
        }
        /// <summary>
        /// 企业OJ问题列表
        /// </summary>
        public webView.hashUrl EnterpriseProblemList
        {
            get { return getPath(examProblem.EnterpriseTopicList); }
        }
    }
}
